Emit a pre-expansion feature gate warning for box'ed struct field patterns#154475
Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom Mar 28, 2026
Merged
Conversation
Collaborator
|
r? @TaKO8Ki rustbot has assigned @TaKO8Ki. Use Why was this reviewer chosen?The reviewer was selected based on:
|
box'ed struct field patterns
fmease
commented
Mar 27, 2026
tests/ui/auto-traits/pre-cfg.rs
Outdated
Member
Author
There was a problem hiding this comment.
Replaced by tests/ui/feature-gates/soft-feature-gate-auto_traits.rs.
fmease
commented
Mar 27, 2026
Member
Author
There was a problem hiding this comment.
Replaced by tests/ui/feature-gates/soft-feature-gate-try_blocks.rs.
This comment has been minimized.
This comment has been minimized.
334925d to
3a5aa21
Compare
This comment has been minimized.
This comment has been minimized.
3a5aa21 to
a7ad9ac
Compare
Member
|
r? me @bors r+ rollup |
Contributor
15 tasks
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 28, 2026
Rollup of 11 pull requests Successful merges: - #152880 (Tweak incorrect assoc item note) - #153526 (Fix LegacyKeyValueFormat report from docker build: i686) - #153613 (interpreter error reporting: remove arguments that are always the same) - #154029 (Replace `truncate(0)` with `clear()`) - #154125 (Inline and remove `DepGraphData::try_mark_parent_green`.) - #154185 (Prevent no_threads RwLock's write() impl from setting mode to -1 when it is locked for reading) - #154394 (Normalize rustc path prefix when testing `-Z track-diagnostics`) - #154450 (Use the normal arg-parsing machinery for `-Zassert-incr-state`) - #154475 (Emit a pre-expansion feature gate warning for `box`'ed struct field patterns) - #154500 (EnumSizeOpt: use Allocation::write_scalar instead of manual endianess logic) - #154502 (interpret: ensure that untupled arguments are actually tuples)
rust-timer
added a commit
that referenced
this pull request
Mar 28, 2026
Rollup merge of #154475 - fmease:soft-gate-box-struct-field-pat, r=Kivooeo Emit a pre-expansion feature gate warning for `box`'ed struct field patterns While the following code triggers a feature gate *warning*: ```rs fn f() { #[cfg(false)] let box x; //~ WARN box pattern syntax is experimental } ``` the code below does not (on stable & main): ```rs fn f() { #[cfg(false)] let Struct { box x }; } ``` This is an oversight as both are part of the unstable feature `box_patterns` (that isn't properly gated pre expansion for historical reasons). Of course, both forms lead to a feature gate error *post expansion*. This is a bug fix and doesn't need any input from T-compiler or T-lang. For context, emitting warnings in these cases is legitimized by [MCP 535](https://github.com/rust-lang/compiler-team/issues/535)[^1]. Part of #154045. [^1]: In case you're wondering why the MCP talks about a *lint* even though the feature gate warnings as seen today don't reference any lint by name, read #154045 (comment).
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Apr 2, 2026
Emit pre-expansion feature gate warnings for negative impls and specialization Follow up to rust-lang#154475; part of rust-lang#154045. This shouldn't need any extra input from T-compiler or T-lang since it's legitimized by [MCP 535](rust-lang/compiler-team#535). However, I have a feeling that negative impls & specialization behind "`#[cfg(feature = "nightly")]`" are more prevalent in the ecosystem compared to e.g., auto traits & box patterns, so these new warnings will probably hit a bunch of users. In any case, it's only a warning for now not an error so e.g., running crater "in deny mode" or nominating for a T-lang meeting discussion would be disproportionate (esp. since T-lang [has confirmed in the past](rust-lang#116393 (comment)) that this is a T-compiler matter).
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Apr 2, 2026
Emit pre-expansion feature gate warnings for negative impls and specialization Follow up to rust-lang#154475; part of rust-lang#154045. This shouldn't need any extra input from T-compiler or T-lang since it's legitimized by [MCP 535](rust-lang/compiler-team#535). However, I have a feeling that negative impls & specialization behind "`#[cfg(feature = "nightly")]`" are more prevalent in the ecosystem compared to e.g., auto traits & box patterns, so these new warnings will probably hit a bunch of users. In any case, it's only a warning for now not an error so e.g., running crater "in deny mode" or nominating for a T-lang meeting discussion would be disproportionate (esp. since T-lang [has confirmed in the past](rust-lang#116393 (comment)) that this is a T-compiler matter).
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Apr 2, 2026
Emit pre-expansion feature gate warnings for negative impls and specialization Follow up to rust-lang#154475; part of rust-lang#154045. This shouldn't need any extra input from T-compiler or T-lang since it's legitimized by [MCP 535](rust-lang/compiler-team#535). However, I have a feeling that negative impls & specialization behind "`#[cfg(feature = "nightly")]`" are more prevalent in the ecosystem compared to e.g., auto traits & box patterns, so these new warnings will probably hit a bunch of users. In any case, it's only a warning for now not an error so e.g., running crater "in deny mode" or nominating for a T-lang meeting discussion would be disproportionate (esp. since T-lang [has confirmed in the past](rust-lang#116393 (comment)) that this is a T-compiler matter).
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Apr 2, 2026
Emit pre-expansion feature gate warnings for negative impls and specialization Follow up to rust-lang#154475; part of rust-lang#154045. This shouldn't need any extra input from T-compiler or T-lang since it's legitimized by [MCP 535](rust-lang/compiler-team#535). However, I have a feeling that negative impls & specialization behind "`#[cfg(feature = "nightly")]`" are more prevalent in the ecosystem compared to e.g., auto traits & box patterns, so these new warnings will probably hit a bunch of users. In any case, it's only a warning for now not an error so e.g., running crater "in deny mode" or nominating for a T-lang meeting discussion would be disproportionate (esp. since T-lang [has confirmed in the past](rust-lang#116393 (comment)) that this is a T-compiler matter).
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Apr 2, 2026
Emit pre-expansion feature gate warnings for negative impls and specialization Follow up to rust-lang#154475; part of rust-lang#154045. This shouldn't need any extra input from T-compiler or T-lang since it's legitimized by [MCP 535](rust-lang/compiler-team#535). However, I have a feeling that negative impls & specialization behind "`#[cfg(feature = "nightly")]`" are more prevalent in the ecosystem compared to e.g., auto traits & box patterns, so these new warnings will probably hit a bunch of users. In any case, it's only a warning for now not an error so e.g., running crater "in deny mode" or nominating for a T-lang meeting discussion would be disproportionate (esp. since T-lang [has confirmed in the past](rust-lang#116393 (comment)) that this is a T-compiler matter).
rust-timer
added a commit
that referenced
this pull request
Apr 2, 2026
Rollup merge of #154527 - fmease:more-soft-gates, r=nnethercote Emit pre-expansion feature gate warnings for negative impls and specialization Follow up to #154475; part of #154045. This shouldn't need any extra input from T-compiler or T-lang since it's legitimized by [MCP 535](rust-lang/compiler-team#535). However, I have a feeling that negative impls & specialization behind "`#[cfg(feature = "nightly")]`" are more prevalent in the ecosystem compared to e.g., auto traits & box patterns, so these new warnings will probably hit a bunch of users. In any case, it's only a warning for now not an error so e.g., running crater "in deny mode" or nominating for a T-lang meeting discussion would be disproportionate (esp. since T-lang [has confirmed in the past](#116393 (comment)) that this is a T-compiler matter).
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Apr 3, 2026
Emit pre-expansion feature gate warnings for negative impls and specialization Follow up to rust-lang/rust#154475; part of rust-lang/rust#154045. This shouldn't need any extra input from T-compiler or T-lang since it's legitimized by [MCP 535](rust-lang/compiler-team#535). However, I have a feeling that negative impls & specialization behind "`#[cfg(feature = "nightly")]`" are more prevalent in the ecosystem compared to e.g., auto traits & box patterns, so these new warnings will probably hit a bunch of users. In any case, it's only a warning for now not an error so e.g., running crater "in deny mode" or nominating for a T-lang meeting discussion would be disproportionate (esp. since T-lang [has confirmed in the past](rust-lang/rust#116393 (comment)) that this is a T-compiler matter).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While the following code triggers a feature gate warning:
the code below does not (on stable & main):
This is an oversight as both are part of the unstable feature
box_patterns(that isn't properly gated pre expansion for historical reasons). Of course, both forms lead to a feature gate error post expansion.This is a bug fix and doesn't need any input from T-compiler or T-lang. For context, emitting warnings in these cases is legitimized by MCP 5351.
Part of #154045.
Footnotes
In case you're wondering why the MCP talks about a lint even though the feature gate warnings as seen today don't reference any lint by name, read https://github.com/rust-lang/rust/issues/154045#issuecomment-4144034419. ↩